/*
 * @Author: your name
 * @Date: 2020-10-20 16:58:32
 * @LastEditTime: 2020-10-21 11:55:31
 * @LastEditors: Please set LastEditors
 * @Description: In User Settings Edit
 * @FilePath: /Project/node/services/FileUploadService.js
 */
const boom = require('boom');
const {querySql, queryOne} = require('../utils')
const {validationResult } = require('express-validator');



/**录入商品 */
function upload(req,res,next) {
    const err = validationResult(req);
    // 如果验证错误，empty不为空
    if (!err.isEmpty()) {
      // 获取错误信息
      console.log("错误:",err);
      const [{ msg }] = err.errors;
      // 抛出错误，交给我们自定义的统一异常处理程序进行错误返回 
      next(boom.badRequest(msg));
    } else {
      console.log("请求参数:",req,"body头:",req.body,"文件:",req.file,"FromData:",req.FromData);

      var paths = [];
    //  for (var i = 0; i < req.files.length; i++) {
    //      var path = req.files[i].path.replace(/\\/g, "/");
    //      var fileurl = uploadFileDomin + path.substr(path.indexOf("uploads")).replace('\\', '/');
    //      paths.push(fileurl);
    //  }
    //  res.status(200).json({
    //      httpCode: 200,
    //      message: '上传成功',
    //      "fileurls": paths,
    //  });

    }
}


module.exports = {
    upload
};